#include "../mqserver/mq_queue.hpp"
#include <gtest/gtest.h>
using namespace wzf;

std::shared_ptr<wzf::MsgQueueManager> qmp;

class QueueTest:public testing::Environment
{
public:
    virtual void SetUp() override
    {
        qmp = std::make_shared<wzf::MsgQueueManager>("./data/test.db");
    }
    virtual void TearDown() override
    {
        qmp->Clear();
        DLOG("clear");
    }
};

// TEST(queue_test, insert_test)
// {
//     std::unordered_map<std::string, std::string> mp {{"key1", "val1"}};
//     qmp->DeclareQueue("queue1", wzf::DeliveryMode::DURABLE, false, false, mp);
//     qmp->DeclareQueue("queue2", wzf::DeliveryMode::DURABLE, false, false, mp);
//     qmp->DeclareQueue("queue3", wzf::DeliveryMode::DURABLE, false, false, mp);
//     qmp->DeclareQueue("queue4", wzf::DeliveryMode::DURABLE, false, false, std::unordered_map<std::string, std::string>());
//     ASSERT_EQ(qmp->Size(), 4);
// } 
TEST(queue_test, select_test)
{   
    std::shared_ptr<MsgQueue> ptr = qmp->SelectQueue("queue1");
    ASSERT_EQ(ptr->name, "queue1");
    ASSERT_EQ(ptr->durable, DeliveryMode::DURABLE);
    ASSERT_EQ(ptr->exclusive, false);
    ASSERT_EQ(ptr->auto_delete, false);
    ASSERT_EQ(ptr->GetArgs(), "key1=val1&");
}
// TEST(queue_test, remove_test)
// {   
//     qmp->DeleteQueue("queue3");
//     ASSERT_NE(qmp->Exists("queue3"), true); 

//     std::shared_ptr<MsgQueue> ptr = qmp->SelectQueue("queue3");
//     ASSERT_EQ(ptr->name, "queue3");
//     ASSERT_EQ(ptr->durable, DeliveryMode::DURABLE);
//     ASSERT_EQ(ptr->exclusive, false);
//     ASSERT_EQ(ptr->auto_delete, false);
//     ASSERT_EQ(ptr->GetArgs(), "key1=val1&");
// }
int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    testing::AddGlobalTestEnvironment(new QueueTest);
    int ret = RUN_ALL_TESTS();
    return 0;
} 